/*!
 * \file tfrlog_error2.c
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 *
 * \version 3.0
 * \author geyh
 * \date 2016/03/31
 *
 */
#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"
#include "frlog.h"
#include "conntrack.h"
#include "frct_comm.h"

#include "apmtest_comm.h"

static int __suite_init(void)
{

    return 0;
}

static int __suite_cleanup(void)
{

    return 0;
}


static void __case1(void)
{
    const char *p_file = (const char *)"file";
    int i_line = 66;
    const char *p_fun = (const char *)"func";
    char *p_data = (char *)frstrdup((char *)"test");

    frlog_error2(p_file,i_line,p_fun,"%s\n",p_data);

    frfree(p_data);
    return;

}

static void __case2(void)
{
    const char *p_file = (const char *)"file";
    int i_line = 66;
    const char *p_fun = (const char *)"func";
    char *p_data = (char *)frstrdup((char *)"test");
    int i_ret = 0;

    i_ret = frlog_open("t_frlog/conf/zlog.conf", "apm_framework");
    if(i_ret != 0)
    {
        frdbg("frlog_open err");
        return;
    }

    frlog_error2(p_file,i_line,p_fun,"%s\n",p_data);

    frlog_close();
    frfree(p_data);
    system("cp t_frlog/logs/framework_error.log t_frlog/t_frlog_error2/case2_out.log");
    system("rm -f t_frlog/logs/framework_error.log");
    return;
}

int add_suite_frlog_error2(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite("frcomm frlog_error2()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    CU_add_test(pSuite, "case1", __case1);
    CU_add_test(pSuite, "case2", __case2);

    return FR_SUCC;
}
